import request from '@/utils/request.ts'
import type { TrademarkList, Trademark } from '@/api/product/trademark/type.ts'

//品牌管理接口
enum API {
  BRAND_URL = '/admin/product/baseTrademark',
  //获取列表接口
  TRADEMARK_URL = '/admin/product/baseTrademark/',
  //分页获取列表接口
  TRADEMARK_PAGE_URL = '/admin/product/baseTrademark/',
  //添加品牌
  ADD_TRADEMARK_URL = '/admin/product/baseTrademark/save',
  //修改品牌
  UPDATE_TRADEMARK_URL = '/admin/product/baseTrademark/update',
  //删除品牌
  DELETE_TRADEMARK_URL = '/admin/product/baseTrademark/remove',
}

export const reqTrademarkList = (page: number, limit: number) =>
  request.get<any, TrademarkList>(API.TRADEMARK_PAGE_URL + `${page}/${limit}`)
//添加或修改品牌
export const reqAddOrUpdateTrademark = (data: Trademark) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATE_TRADEMARK_URL, data)
  } else {
    return request.post<any, any>(API.ADD_TRADEMARK_URL, data)
  }
}
//删除品牌
export const reqDeleteTrademark = (id: number) =>
  request.delete<any, any>(API.DELETE_TRADEMARK_URL + `/${id}`)
